import wyrequest from '@/utils/wyrequest'
import request from '@/utils/request'

// 轮播数据
export interface focusListModel {
    picUrl: string,
    expireTime: number,
    extra: any,
    name: string,
    onlineTime: number,
    id: number,
    originSchemeUrl: string,
    targetUrl: string,
}

// 标签页
export interface kingKongModuleModel {
    norColor: string,
    background: string,
    kingKongList: kingKongListModel[],
    selectedColor: string,
}

export interface kingKongListModel {
    picUrl: string,
    schemeUrl: string,
    text: string,
    textColor: string,
}

// 网易自营品牌
export interface policyDescListModel {
    icon: string,
    schemeUrl: string,
    desc: string,
}

// 新人专享礼
export interface indexActivityModuleModel {
    backgroundUrl: string,
    picUrl: string,
    activityPrice: string,
    subTitle: string,
    originPrice: string,
    tag: string,
    title: string,
    targetUrl: string,
    showPicUrl: string,
}

// 类目热销榜

export interface categoryHotSellModuleModel {
    titleTargetUrl: string,
    categoryList: categoryListModel[],
    title: string
}

export interface categoryListModel {
    picUrl: string,
    extra: extractModel,
    itemPicBeanList: itemPicBeanList[],
    categoryName: string,
    targetUrl: string,
    showPicUrl: string,
}
// 类目热销榜中的数据
export interface itemPicBeanList {
    itemId: number,
    picUrl: string
}

export interface extractModel {
    crmType: number,
    operationResource: operationResource,
    modelType: number,
}

export interface operationResource {
    itemIdList: string[],
    categoryName: string,
    categoryId: string
}

export interface cellsModel {
    subTitleColor: string,
    rcmdItem: boolean,
    schemeUrl: string,
    title: string,
    picUrl: string,
    rcmdSort: boolean,
    itemCnt: number,
    itemFrom: number,
    subTitle: string,
    titleColor: string,
    showPrice: boolean,
    extra: any,
    popupUrl: string,
    leftTime: number,
    itemList: any,
    id: string,
    targetUrl: string,
}

export interface floorListModel {
    layout: number,
    cells: cellsModel[],
    columnNum:  number,
    floorType: number, 
    style:  number,
    taskId:  number,
    height:  number,
}

export interface bigPromotionModuleModel {
    floorList: floorListModel[]
}

export interface homeModel {
    bigPromotionModule: bigPromotionModuleModel, // 周年狂欢
    tagList: any,
    policyDescList: policyDescListModel[], // 网易自营品牌
    popularItemList: any,
    categoryHotSellModule: categoryHotSellModuleModel,// 类目排行榜
    freshmanFlag: any,
    focusList: focusListModel[], // 轮播
    sceneLightShoppingGuideModule: any,// 趣出游、严选直播
    kingKongModule: any, // 标签页
    indexActivityModule: indexActivityModuleModel[], // 新人专享礼
}

export interface dataModel {
    data: homeModel
}

// 请求卡片接口
export interface reqSearchInfoParamsModel {
    category3Id: string, // 三级分类
    categoryName: string, // 三级分类
    keyword: string, // 搜索
    trademark: string, // 品牌  "4:小米"   `品牌id:品牌名称`  `tmId:tmName`
    props: any, // 平台属性 ["1:1700-2799:价格"] [`平台属性id:平台属性值:平台属性名`]  [`attrId:attrValue:attrName`]
    order: string, // 排序   1 综合 2 价格     desc 降序 asc 升序   默认`1:desc`是`综合:降序`
    pageNo: number, // 当前页
    pageSize: number, // 每页条数
}

// 卡片数据回来的数据
export interface reqSearchInfoData {
    goodsList: goodsListModel[]
}

export interface goodsListModel {
    attrs: any,
    category1Id: any,
    category1Name: any,
    category2Id: any,
    category2Name: any,
    category3Id: any,
    category3Name: any,
    createTime: any,
    defaultImg: string,
    hotScore: number,
    id: number,
    price: number,
    title: string,
    tmId: any,
    tmName: any,
}


export default {
    getHomeData() {
        return wyrequest.get<any, dataModel>('/xhr/index.json?__timestamp=1630131808529')
    },
    reqSearchInfo(params: reqSearchInfoParamsModel) {
        return request.post<any, reqSearchInfoData>(`/list`, params)
    },
}